/**
 * 
 */
package com.base.myproject.client.busi.system;

import com.base.myproject.client.tools.SendServlet;
import com.extjs.gxt.ui.client.widget.Html;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;

/**
 * @author zgw
 *2009-11-7 下午12:28:46
 * javazgw@gmail.com
 */
public class BcodeOrganization implements RequestCallback{

	String filter;
	//String html;
	Html html =new Html();
	/**
	 * 
	 * @param filter 格式 " bcode like '1%25'"
	 */
	public BcodeOrganization(String filter)
	{
		this.filter = filter;
		init();
	}
	
	void init()
	{
		
	}
	
	public boolean load()
	{
		SendServlet ss = new SendServlet();
		try {
			ss.sendServlet("BaseServlet", "Action=getorganization&filter="+filter,"root","1", this);
			
		} catch (RequestException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public void onError(Request request, Throwable exception) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onResponseReceived(Request request, Response response) {
		
		//html = response.getText();
		System.out.println(response.getText());
		html.setHtml(response.getText());
		html.setAutoWidth(true);
//		   RootPanel.get("zgwtest").add(h);
		//execjavascript();
	}
	
	
	/**
	 * @return the html
	 */
	public Html getHtml() {
		return html;
	}

	/**
	 * @param html the html to set
	 */
	public void setHtml(Html html) {
		this.html = html;
	}

	/**
	 * 执行javascript
	 * 注意javascript文件里面必须有addClasses和hugSiteMap 否则显示不正常
	 * @return
	 */
	private native String execjavascript() /*-{
	 
		$wnd.alert("ee");
		$wnd.addClasses();
		$wnd.hugSiteMap();
		
	  }-*/;
}
